package com.itboye.mengwu.widget;

import com.itboye.core.alert.ByAlert;
import com.itboye.mengwu.R;
import com.itboye.mengwu.app.ui.roof.ActivityBaoShuiQu;
import com.itboye.mengwu.data.model.GoodsListModel;
import com.itboye.mengwu.data.presenter.AddGoodsPresenter;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

public class MorePopWindow extends PopupWindow {
	private View conentView;
	LinearLayout linZonghe;
	LinearLayout linJiageGao;
	LinearLayout linJiageDi;
	
	AddGoodsPresenter addGoodsPresenter;
	GoodsListModel goodsListModel = new GoodsListModel();
	
	public MorePopWindow(final Activity context,View view,View ooo) {
		
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//		conentView = inflater.inflate(R.layout.more_popup_dialog, null);
		int h = context.getWindowManager().getDefaultDisplay().getHeight();
		int w = context.getWindowManager().getDefaultDisplay().getWidth();
		// 设置SelectPicPopupWindow的View
		this.setContentView(conentView);
		// 设置SelectPicPopupWindow弹出窗体的宽
		this.setWidth(w);
		// 设置SelectPicPopupWindow弹出窗体的高
		this.setHeight(LayoutParams.WRAP_CONTENT);
		// 设置SelectPicPopupWindow弹出窗体可点击
		this.setFocusable(true);
		this.setOutsideTouchable(true);
		// 刷新状态
		this.update();
		// 实例化一个ColorDrawable颜色为半透明
		ColorDrawable dw = new ColorDrawable(0000000000);
		ActivityBaoShuiQu.imgBaoSui.setBackgroundResource(R.drawable.weixin);
		// 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ，设置其他控件变化等操作
		this.setBackgroundDrawable(dw);
//		LinearLayout linZonghe=(LinearLayout) conentView.findViewById(R.id.linZonghe);
//		linZonghe.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//			ByAlert.alert("综合彭家");	
//			ActivityBaoShuiQu.imgBaoSui.setBackgroundResource(R.drawable.logo);
//			ActivityBaoShuiQu.renqi.setText("综合排序");
//			}
//		});
//		
//		LinearLayout linJiageGao=(LinearLayout) conentView.findViewById(R.id.linJiageGao);
//		linJiageGao.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				ActivityBaoShuiQu.renqi.setText("价格高到低");
//			}
//		});
//		LinearLayout linJiageDi=(LinearLayout) conentView.findViewById(R.id.linJiageDi);
//		linJiageDi.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				ActivityBaoShuiQu.renqi.setText("价格低到高");
//				
//			}
//		});
		// mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
		// 设置SelectPicPopupWindow弹出窗体动画效果
//		this.setAnimationStyle(R.style.AnimationPreview);

	}

	public void showPopupWindow(View parent) {
		if (!this.isShowing()) {
			this.showAsDropDown(parent, parent.getLayoutParams().width / 2, 18);
		} else {
			this.dismiss();
		}
	}
	
}
